package priv.dajie.tzzq.spider.test;

import java.util.ArrayList;
import java.util.Queue;
import java.util.concurrent.ArrayBlockingQueue;

public class test extends Thread{

    private ls l;
    private String name;

    public test(ls l, String name){
        this.l = l;
        this.name = name;
    }

    public static void main(String[] args) {
        Queue<String> queue = new ArrayBlockingQueue(100);
        queue.add("555");
        System.out.println(queue.poll());
        System.out.println(queue.poll());
    }


    @Override
    public void run() {
        while (!l.isEmpty()){
            System.out.println(name+ ": " +l.get());
        }
    }
}

class ls{
    private ArrayList<Integer> list;

    public ls(){
        list = new ArrayList();
        for (int i =0;i<10;i++)
            list.add(i);
    }

    public int get(){
        synchronized(this) {
            return list.remove(0);
        }
    }

    public boolean isEmpty(){
        return list.isEmpty();
    }
}